import 'dart:typed_data';


//询查标签
inventoryWithAnt(String ant){
  int antByte = int.parse("0x${int.parse(ant).toRadixString(16).padLeft(2,'0')}");
  var array = [0xdd, 0x11, 0xef, 0x09,  antByte, 0x01, 0x00,0x00,0x00];
  // var (byte1,byte2) = analyzeCRC(array);
  // array.add(byte1);
  // array.add(byte2);
  Uint8List bytes = Uint8List.fromList(array);
  print(bytes);
  return bytes;
}

//空包
empty(){
  var array = [0x00];
  Uint8List bytes = Uint8List.fromList(array);
  print(bytes);
  return bytes;
}

//询查标签
inventoryAll(){
  var array = [0xdd, 0x11, 0xef, 0x09, 0xff, 0x01, 0x00,0x00,0x00];
  Uint8List bytes = Uint8List.fromList(array);
  print(bytes);
  return bytes;
}
//读块
readBlock(String tid,String ant){
  List<int> uids = [];
  if(tid.length%2 == 1){
    tid = "${tid}0";
  }
  int length = tid.length;
  int i = 0;
  while(i<length){
    var u = int.parse("0x${tid.substring(i,i+2)}");
    uids.add(u);
    i = i+2;
  }

  int antByte = int.parse("0x${int.parse(ant,radix: 16).toRadixString(16).padLeft(2,'0')}");
  var array = [0xdd, 0x11, 0xef, 0x13, antByte, 0x23, 0x01];
  array.addAll(uids);
  array.addAll([0x00,0x03,0x00,0x00]);
  Uint8List bytes = Uint8List.fromList(array);
  print(bytes);
  return bytes;
}
